//
// Created by hamlet on 2022/1/11.
//

#ifndef TIANQI_MAINPROCESS_H
#define TIANQI_MAINPROCESS_H

#include <QObject>
#include <QSystemTrayIcon>

class TianqiAccesser;
class MainWindow;

QT_BEGIN_NAMESPACE
class QAction;
class QMenu;
QT_END_NAMESPACE

class MainProcess : public QObject {
Q_OBJECT
public:
    explicit MainProcess(QObject *parent = nullptr);
    ~MainProcess() override;

private slots:
    void iconActivated(QSystemTrayIcon::ActivationReason reason);
    void showMainWindow();
    void showSettingsDialog();

    void freeMemory();  // 释放内存
    void updatePage();  // 获取到数据后更新页面

private:
    TianqiAccesser *m_tianqiAccesser;
    MainWindow *m_mainWindow;

    void setMainWindowEnabled(bool state);  // state为true分配内存；false释放内存

    QAction *m_refreshAction;
    QAction *m_settingsShowAction;
    QAction *m_showAction;
    QAction *m_quitAction;
    QMenu   *m_trayIconMenu;

    QSystemTrayIcon *m_trayIcon;
};


#endif //TIANQI_MAINPROCESS_H
